<?php

use yii\db\Migration;

class m170912_082355_create_mechanicsettlementrelaction extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->createTable('{{%mechanic_settlement_relation}}',[
                'mechanic_settlement_id' => $this->integer()->defaultValue(0).' COMMENT \'计算id\'',
                'mechanic_subsidy_divided_id' => $this->integer()->defaultValue(0).' COMMENT \'补贴/分成表id\'',
                'type' => $this->smallInteger(1)->defaultValue(0).' COMMENT \'1 补贴 2 分成\'',
            ]);
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v){
            $this->db = $v;
            $this->dropTable('{{%mechanic_settlement_relation}}');
        }
    }
}
